#ifndef EVENT_MANAGER_H
#define EVENT_MANAGER_H

#include <stdbool.h>
#include "closure.h"

#include "nodelevel_aggregator.h"



typedef void * PtrType;

#define EVT_ANY ((PtrType)(-1))
#define EVT_PARAM(HDL,ARG) HDL,ARG
#define EVT_NOPARAM(HDL) HDL,NULL






/* Example :
  #define EVT_PAGE_ARRIVED(X) EVT_PARAM(evt_page_arrived_hdl,X)
  #define EVT_TAST_END EVT_NOPARAM(evt_task_end_hdl)
 */


struct evt_properties {
    bool evtp_is_state_event;
    bool evtp_is_thread_local;
    bool (*state_indicator)(void *);
    bool evtp_has_argument;
    delegate_lock_p lock;
    char * evtp_name;
};




typedef struct action action_t;
typedef struct action * action_p;
typedef struct evt_handle *evthdl;


#define action_for_events( A,... )\
    on_event(A, __VA_ARGS__)

evthdl init_event( struct evt_properties * properties );
void on_event( Closure *c ,  ...);
void signal_event( evthdl e, void * arg );





#endif // EVENT_MANAGER_H
